package org.edu.modules.classChoise.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.edu.common.api.vo.Result;
import org.edu.common.aspect.annotation.AutoLog;
import org.edu.common.system.base.controller.BaseController;
import org.edu.common.system.query.QueryGenerator;
import org.edu.modules.classChoise.entity.VeJwXkxzxs;
import org.edu.modules.classChoise.service.IVeJwXkxzxsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;

/**
* @Description: 选课限制
* @Author:
* @Date:   2021-05-14
* @Version: V1.0
*/
@Api(tags="选课限制学生")
@RestController
@RequestMapping("/classChoise/veJwXkxzxs")
@Slf4j
public class VeJwXkxzxsController extends BaseController<VeJwXkxzxs, IVeJwXkxzxsService> {
   @Autowired
   private IVeJwXkxzxsService veJwXkxzxsService;

    /**
     * 分页查询
     * @param veJwXkxzxs
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "选课模式课程明细-分页查询")
    @ApiOperation(value="分页查询", notes="选课模式课程明细-分页查询")
    @PostMapping(value = "/list")
    public Result<?> queryPageList(VeJwXkxzxs veJwXkxzxs,
                                   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                   @RequestParam(name="pageSize", defaultValue="999") Integer pageSize,
                                   HttpServletRequest req) {
        QueryWrapper<VeJwXkxzxs> queryWrapper = QueryGenerator.initQueryWrapper(veJwXkxzxs, req.getParameterMap());
        Page<VeJwXkxzxs> page = new Page<VeJwXkxzxs>(pageNo, pageSize);
        IPage<VeJwXkxzxs> pageList = veJwXkxzxsService.page(page, queryWrapper);
        return Result.OK(pageList);
    }
   /**
    * 新增信息
    * @param veJwXkxzxs
    * @return
    */
   @AutoLog(value = "选课限制-新增信息")
   @ApiOperation(value="新增限制学生", notes="选课限制-新增限制学生")
   @PostMapping(value = "/add")
   public Result<?> add(@RequestBody VeJwXkxzxs veJwXkxzxs) {
       if(veJwXkxzxsService.save(veJwXkxzxs)){
          return Result.OK("添加成功！");
       }
       return Result.error("添加失败!");
   }


}
